import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { HttpClientModule } from '@angular/common/http';
import { FormsModule } from '@angular/forms';
import { RouterModule, Routes } from '@angular/router';
import { CommonModule , HashLocationStrategy , LocationStrategy } from '@angular/common';

import { AppComponent } from './app.component';

// service
import { BookService } from './services/book.service';
import { GlobalSettingService } from './services/global-setting.service';
import { PublisherService } from './services/publisher.service';
import { CategoryService } from './services/category.service';
import { AccountService } from './services/account.service';
import { AuthorService } from './services/author.service';
import { AdvertiseService } from './services/advertise.service';
import { SectionService } from './services/section.service';
import { TransactionService } from './services/transaction.service';

// angular material
import {
  MatButtonModule, MatCheckboxModule, MatCardModule,
  MatGridListModule, MatDividerModule, MatListModule,
  MatSidenavModule, MatFormFieldModule, MatSelectModule,
  MatIconModule, MatInputModule, MatMenuModule, MatDialogModule,
} from '@angular/material';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

// components
import { FooterComponent } from './components/common/footer/footer.component';
import { ContentComponent } from './components/common/content/content.component';
import { CoverComponent } from './components/common/cover/cover.component';
import { BooklistComponent } from './components/common/booklist/booklist.component';
import { SearchComponent } from './components/common/search/search.component';
import { HomeMainComponent } from './components/home/home-main/home-main.component';
import { HomeSliderComponent } from './components/home/home-slider/home-slider.component';
import { CategoryMainComponent } from './components/category/category-main/category-main.component';
import { ExploreMainComponent } from './components/explore/explore-main/explore-main.component';
import { UserMainComponent } from './components/user/user-main/user-main.component';
import { LoginComponent } from './components/common/account/login/login.component';
import { RegisterComponent } from './components/common/account/register/register.component';
import { BookdetailComponent } from './components/common/bookdetail/bookdetail.component';
import { HomeSectionComponent } from './components/home/home-section/home-section.component';
import { TopbarWordComponent } from './components/common/topbar/topbar-word/topbar-word.component';
import { TopbarInputComponent } from './components/common/topbar/topbar-input/topbar-input.component';
import { BookcaseComponent } from './components/common/bookcase/bookcase.component';
import { BookcaselistComponent } from './components/common/bookcaselist/bookcaselist.component';
import { SearchlistComponent } from './components/common/searchlist/searchlist.component';
import { SettingsComponent } from './components/common/settings/settings.component';
import { ResetComponent } from './components/common/account/reset/reset.component';
import { CodeComponent } from './components/common/account/code/code.component';
import { HomeListComponent } from './components/home/home-list/home-list.component';
import { HomeRecommendComponent } from './components/home/home-recommend/home-recommend.component';
import { DialogComponent } from './components/common/dialog/dialog.component';





const routing: Routes = [
  { path: '', redirectTo: 'cover', pathMatch: 'full' },
  { path: 'cover', component: CoverComponent },
  {
    path: 'content', component: ContentComponent,
    children: [
      { path: '', redirectTo: 'home', pathMatch: 'full' },
      { path: 'home', component: HomeMainComponent },
      { path: 'category', component: CategoryMainComponent },
      { path: 'explore', component: ExploreMainComponent },
      { path: 'user', component: UserMainComponent },
    ]
  },
  { path: 'search', component: SearchComponent },
  { path: 'reset', component: ResetComponent },
  { path: 'code/:phone', component: CodeComponent },
  { path: 'bookcase', component: BookcaseComponent },
  { path: 'bookcaselist', component: BookcaselistComponent },
  { path: 'settings', component: SettingsComponent },
  { path: 'searchlist/:keyword', component: SearchlistComponent },
  { path: 'bookdetail/:id', component: BookdetailComponent },
  { path: 'booklist/:id/:name', component: BooklistComponent },
  { path: 'homelist/:id/:name', component: HomeListComponent },
  { path: 'login', component: LoginComponent },
  // { path: 'register', component: RegisterComponent }
];




@NgModule({
  declarations: [
    AppComponent,
    FooterComponent,
    ContentComponent,
    CoverComponent,
    BooklistComponent,
    SearchComponent,
    HomeMainComponent,
    HomeSliderComponent,
    CategoryMainComponent,
    ExploreMainComponent,
    UserMainComponent,
    LoginComponent,
    RegisterComponent,
    BookdetailComponent,
    HomeSectionComponent,
    TopbarWordComponent,
    TopbarInputComponent,
    BookcaseComponent,
    BookcaselistComponent,
    SearchlistComponent,
    SettingsComponent,
    ResetComponent,
    CodeComponent,
    HomeListComponent,
    HomeRecommendComponent,
    DialogComponent,
  ],
  imports: [
    BrowserModule,
    HttpClientModule,
    FormsModule,
    RouterModule.forRoot(routing,{useHash:true}),
    MatButtonModule, MatCheckboxModule, MatSelectModule,
    BrowserAnimationsModule, MatCardModule, MatGridListModule,
    MatDividerModule, MatListModule, MatSidenavModule,
    MatFormFieldModule, MatIconModule, MatInputModule,
    MatMenuModule, MatDialogModule
  ],
  exports: [
    RouterModule,
    MatButtonModule, MatCheckboxModule, MatSelectModule,
    BrowserAnimationsModule, MatCardModule, MatGridListModule,
    MatDividerModule, MatListModule, MatSidenavModule,
    MatFormFieldModule, MatIconModule, MatInputModule,
    MatMenuModule, MatDialogModule
  ],
  providers: [
    BookService,
    GlobalSettingService,
    PublisherService,
    CategoryService,
    AccountService,
    AuthorService,
    AdvertiseService,
    SectionService,
    TransactionService,
    {provide:LocationStrategy,useClass:HashLocationStrategy}
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }

